package com.ruoyi.userMission.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.userMission.domain.ro.FloorToUserMissionRo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.userMission.domain.HsUserMission;
import com.ruoyi.userMission.service.IHsUserMissionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户核酸任务管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-29
 */
@RestController
@RequestMapping("/userMission/userMission")
public class HsUserMissionController extends BaseController
{
    @Autowired
    private IHsUserMissionService hsUserMissionService;

    /**
     * 查询用户核酸任务管理列表
     */
    @PreAuthorize("@ss.hasPermi('userMission:userMission:list')")
    @GetMapping("/list")
    public TableDataInfo list(HsUserMission hsUserMission)
    {
        startPage();
        List<HsUserMission> list = hsUserMissionService.selectHsUserMissionList(hsUserMission);
        return getDataTable(list);
    }
    /**
     * 获取用户任务管理状态表所有信息
     */
    @GetMapping("/status")
    public AjaxResult getUMissionStatus()
    {
        return success(hsUserMissionService.getUMissionStatus());
    }

    /**
     * 获取所有任务名字
     * */

    @GetMapping("/missionName")
    public AjaxResult getMissionName()
    {
        return success(hsUserMissionService.getMissionName());
    }
    /**
     * 导出用户核酸任务管理列表
     */
    @PreAuthorize("@ss.hasPermi('userMission:userMission:export')")
    @Log(title = "用户核酸任务管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HsUserMission hsUserMission)
    {
        List<HsUserMission> list = hsUserMissionService.selectHsUserMissionList(hsUserMission);
        ExcelUtil<HsUserMission> util = new ExcelUtil<HsUserMission>(HsUserMission.class);
        util.exportExcel(response, list, "用户核酸任务管理数据");
    }

    /**
     * 获取用户核酸任务管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('userMission:userMission:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hsUserMissionService.selectHsUserMissionById(id));
    }

    /**
     * 新增用户核酸任务管理
     */
    @PreAuthorize("@ss.hasPermi('userMission:userMission:add')")
    @Log(title = "用户核酸任务管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HsUserMission hsUserMission)
    {
        return toAjax(hsUserMissionService.insertHsUserMission(hsUserMission));
    }

    /**
     * 新增用户核酸任务管理 从楼栋管理过来
     */

    @PostMapping("/floorMissionAdd")
    public AjaxResult addFloorUserMission(@RequestBody FloorToUserMissionRo floorToUserMissionRo)
    {
        return toAjax(hsUserMissionService.addFloorUserMission(floorToUserMissionRo));
    }

    /**
     * 修改用户核酸任务管理
     */
    @PreAuthorize("@ss.hasPermi('userMission:userMission:edit')")
    @Log(title = "用户核酸任务管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HsUserMission hsUserMission)
    {
        return toAjax(hsUserMissionService.updateHsUserMission(hsUserMission));
    }

    /**
     * 删除用户核酸任务管理
     */
    @PreAuthorize("@ss.hasPermi('userMission:userMission:remove')")
    @Log(title = "用户核酸任务管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hsUserMissionService.deleteHsUserMissionByIds(ids));
    }
}
